package com.itheima.exerciseTest.method30_39.method32;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class ServerDemo {
    public static void main(String[] args) throws IOException {
        int port = 10000;
        DatagramSocket ds = new DatagramSocket(port);
        while (true){
            byte[] bytes = new byte[1024];
            DatagramPacket dp = new DatagramPacket(bytes,bytes.length);
            ds.receive(dp);
            String str = new String(bytes,0,dp.getLength());
            if("886".equals(str)){
                System.out.println("接收端关闭");
                break;
            }
            System.out.println(str);
        }
        ds.close();
    }
}
